//
//  ViewController.m
//  FicowStepper
//
//  Created by ficow on 16/3/17.
//  Copyright © 2016年 ficow. All rights reserved.
//

#import "ViewController.h"
#import "FicowStepper.h"

@interface ViewController ()<UITextFieldDelegate>

@property (nonatomic, strong) FicowStepper *myStepper;

@property (nonatomic, strong) FicowStepper *defaultStepper;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    float width = 260.0f;
    float screenWidth = [UIScreen mainScreen].bounds.size.width;
    float x = (screenWidth - width) / 2.0;
    self.view.backgroundColor = [UIColor grayColor];
    self.myStepper = [[FicowStepper alloc]initWithFrame:CGRectMake(x, 200, 200, 40)];
    [self.myStepper setDefaultStyle:FicowStepperStyleDefault1];
    
//    self.myStepper.value = 1.0f;
//    self.myStepper.maximum = 1000.0f;
//    self.myStepper.minimum = 0.0f;
    self.myStepper.hidesIncrementWhenMaximum = YES;
    self.myStepper.hidesDecrementWhenMinimum = YES;
    self.myStepper.countField.returnKeyType = UIReturnKeyDone;
    
    self.myStepper.valueChangedCallback = ^(FicowStepper *stepper,float count){
        stepper.countField.text = [NSString stringWithFormat:@"%@",@(count)];
    };
    
    [self.myStepper setup];
    [self.view addSubview:self.myStepper];
    
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [self.view endEditing:YES];
}

#pragma mark --- delegate ---

- (BOOL)textFieldShouldReturn:(UITextField *)textField{
    [textField resignFirstResponder];
    return YES;
}


@end
